package com.kaishengit.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.pojo.Goal;
import com.kaishengit.pojo.Project;
import com.kaishengit.pojo.User;
import com.kaishengit.util.CreateTime;
import com.kaishengit.util.MyUUID;

@Service
@Transactional
public class GoalService extends BaseService{

	public List<Goal> finAll(Project project){
		List<Goal> goalList=getGoalDao().findAllByPro(project);
		return goalList;
	}
	public Goal findById(String id) {
		return getGoalDao().findById(id);
	}

	public void save(Goal goal,User user,Project project) {
		goal.setId(MyUUID.createUUID().toString());
		goal.setCreatetime(CreateTime.createTime());
		goal.setUser(user);
		goal.setProject(project);
		getGoalDao().save(goal);
	}
	public void update(Goal goal, String id) {
		Goal g=getGoalDao().findById(id);
		g.setContent(goal.getContent());
		g.setName(goal.getName());
		getGoalDao().save(g);
	}
	/*public int findrates(){
		
		
	}*/
	public List<Goal> findByUser(User user) {
		return getGoalDao().findByUser(user);
		
		
		
	}
}
